<?php


namespace app\common\model;


class AppointmentRecord extends BaseModel
{

    protected $name = 'appointment_record';

    protected $updateTime = false;


    public static function addRecord($order_id, $name = '管理员', $type)
    {

        if(!$order_id){
            return false;
        }

        switch ($type){
            case 1:
                $str = $name. '预约下单成功';
                break;
            case 2:
                $str = '管理员操作分配人员，客户收到推送消息状态为:'.$name;
                break;
            case 3:
                $str = '管理员操作上门人员，工作人员收到推送消息状态为:'.$name;
                break;
            case 4:
                $str = '服务人员:'.$name.'->确认时间成功';
                break;
            case 5:
                $str = '服务人员:'.$name.'->确认开始服务成功';
                break;
            case 6:
                $str = '客户确认服务成功';
                break;
            case 7:
                $str = '服务人员已拨打电话';
                break;
        }

        if(!isset($str)){
            return false;
        }

        $data = [
            'order_id'=>$order_id,
            'wxapp_id'=>Self::$wxapp_id,
            'info'=>$str
        ];

        (new Self)->save($data);

        return true;
    }

    public function getList($order_id)
    {
        if(!$order_id){
            return false;
        }

        $list = Self::all(['order_id'=>$order_id]);

        return $list;
    }

    public function getCreateTimeAttr($val)
    {
        return date('Y-m-d H:i:s',$val);
    }
}